package car.activities;


import car.manager.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;
import android.view.View;


public class GarageManagerActivity extends Activity {

	
	private ImageView garage;
	private ImageAdapter imageAdapter;

	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.garage_manager);

	    Gallery gallery = (Gallery) findViewById(R.id.gallery);
	    imageAdapter = new ImageAdapter(this);
	    gallery.setAdapter(imageAdapter);
	    garage = (ImageView) findViewById(R.id.imageViewAmplifiedGarage);
	    garage.setImageResource(R.drawable.garage1);

	   
	    gallery.setOnItemClickListener(new OnItemClickListener() {
	    	
	        public void onItemClick(AdapterView parent, View v, int position, long id) {
	        	
	        	
//	    	    int i = (int) imageAdapter.getItemId(position);
//	    	    garage.setImageResource(i);
	    	  
	        	int resourceId = imageAdapter.getImageId(position);
	    	    garage.setImageResource(resourceId);
	        	
	            Toast.makeText(GarageManagerActivity.this, "" + position, Toast.LENGTH_SHORT).show();
	        }
	    });
	}
	
}
